class Solution {
public:
    int characterReplacement(string s, int k) {
        int r =0,l=0;
        unordered_map<char,int> hash;
        int ret =0;
        int tmp =0;
        while(r<s.size()){
            hash[s[r]]++;
            tmp = max(tmp,hash[s[r]]);
            while(r-l+1>tmp+k)
                hash[s[l++]]--;
            ret = max(ret,r-l+1);
            r++;
        }
        return ret;
    }
};
class Solution {
public:
    int longestOnes(vector<int>& nums, int k) {
        int l =0,r=0;
        int len =0,zreo=0;
        while(r<nums.size())
        {
            if(nums[r]==0) zreo++;
            while(zreo>k)
                if(nums[l++]==0) zreo--;
            len =max(len,r-l+1);
            r++;
        }
        return len;
    }
};